package com.bulk.hutool.img;

import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.io.FileUtil;

import java.awt.image.BufferedImage;
import java.io.File;

/**
 * img 九宫格切割
 *
 * @author 散装java
 * @date 2022-08-19
 */
public class ImgTest {
    public static void main(String[] args) {
        File file = FileUtil.file("d:/tmp/test.jpg");
        BufferedImage read = ImgUtil.read(file);
        int width = read.getWidth();
        int height = read.getHeight();
        // +1 是为了向上取整。不然多月的长度会单独形成一个图片
        int cutWidth = width / 3 + 1;
        int cutHeight = height / 3 + 1;
        ImgUtil.slice(file, FileUtil.file("d:/tmp/img"), cutWidth, cutHeight);
    }
}
